<template>
	<view class="page">
		<view class="block swiper-block">
			<swiper autoplay="true" indicator-color="#999" indicator-active-color="#fff" class="swiper-item">
				<swiper-item :item-id="item.id" v-for="(item,index) in swiperList" :key="item.id" class="bg-item">
					<image :src="cloudStorage+item.url" class="bg-img"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="menu-block">
			<view class="left-block" @click="navigate('/pages/reflect/reflect')"
				style="background: url('https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/reflect.png') no-repeat center;background-size: 100%;">
				<view class="left-title">
					<view class="name">我要反映问题</view>
					<view class="iconfont icon-youjiantou"></view>
				</view>
				<view class="btn FZHZGBJ">点击查看</view>
			</view>
			<view class="right-block" @click="navigate('/pages/contact/contact')"
				style="background: url('https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/contact.png') no-repeat center;background-size:  100%;">
				<view class="right-title">
					<view class="name">我要联系巡察组</view>
					<view class="iconfont icon-youjiantou"></view>
				</view>
				<view class="btn FZHZGBJ">点击查看</view>
			</view>
		</view>
		<view class="info-block">
			<view class="title-block">
				<view class="title-item">
					<view class="line"></view>
					<view class="title">巡察公告</view>
				</view>
				<view class="more" @click="navigate('/pages/notice/notice')">
					查看全部
					<view class="iconfont icon-a-gengduo1"></view>
				</view>
			</view>
			<template v-if="noticeList.length>0">
				<NoticeList v-for="item in noticeList" :key="item.id" :info="item"></NoticeList>
			</template>
			<view class="empty" v-else>暂无数据</view>
			<view class="title-block">
				<view class="title-item">
					<view class="line"></view>
					<view class="title">巡察动态</view>
				</view>
				<view class="more" @click="navigate('/pages/dynamics/dynamics')">
					查看全部
					<view class="iconfont icon-a-gengduo1"></view>
				</view>
			</view>
			<template v-if="dynamicsList.length>0">
				<DynamicsList v-for="item in dynamicsList" :key="item.id" :info="item"></DynamicsList>
			</template>
			<view class="empty" v-else>暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		DynamicsList
	} from '@/components/DynamicsList/DynamicsList.vue'
	import {
		NoticeList
	} from '@/components/NoticeList/NoticeList.vue'
	import {
		getArticleListApi,
		getBannerListApi
	} from '@/api/home.js'
	export default {
		components: {
			NoticeList,
			DynamicsList
		},
		data() {
			return {
				topBgColor: 'rgba(0,0,0,0)',
				swiperList: [],
				dynamicsList: [],
				noticeList: [],
			}
		},
		watch: {

		},
		methods: {
			getSwiperList() {
				getBannerListApi().then(res => {
					this.swiperList = res
				})
			},
			getDynamicsList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getArticleListApi({
					page: 1,
					limit: 2,
					type: 2
				}).then(res => {
					this.dynamicsList = res.list
				})
			},
			getNoticeList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getArticleListApi({
					page: 1,
					limit: 2,
					type: 1
				}).then(res => {
					this.noticeList = res.list
				})
			},
			//onShareAppMessage 分享给朋友
			onShareAppMessage: function(res) {
				if (res.from === 'button') {

				}
				return {
					title: '玉你同巡',
					path: '/pages/index/index'
				}
			},
			onShareTimeline() { // 分享到朋友圈
				return {
					title: '玉你同巡',
					path: '/pages/index/index'
				}
			},
		},
		onShow() {
			this.getDynamicsList();
			this.getNoticeList();
			this.getSwiperList()
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		overflow: hidden;
		min-height: 100vh;
		background-color: #F7F6F9;

		.block.swiper-block {
			height: 550rpx;
			width: 100%;

			.swiper-item {
				width: 100%;
				height: 550rpx;

				.bg-item {
					width: 100%;
					height: 550rpx;

					.bg-img {
						width: 100%;
						height: 550rpx;
					}
				}
			}
		}

		.menu-block {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: absolute;
			top: 250px;

			.left-block {
				width: calc(50% - 20rpx);
				height: 150rpx;
				padding: 30rpx;
				border-radius: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				color: #fff;
				margin-left: 15rpx;

				.left-title {
					display: flex;
					align-items: center;
					margin-top: 5rpx;

					.name {
						font-size: 34rpx;
						font-weight: bold;
						margin-right: 14rpx;
					}

					.iconfont {
						color: #d5dcf0;
						font-size: 40rpx
					}
				}

				.text {
					font-size: 28rpx;
					margin-top: 30rpx;
				}

				.btn {
					width: 160rpx;
					height: 90rpx;
					background-color: #fff;
					color: #3153b5;
					font-size: 28rpx;
					margin-top: 10rpx;
					box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
				}
			}

			.right-block {
				width: calc(50% - 20rpx);
				height: 150rpx;
				padding: 30rpx;
				border-radius: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				color: #fff;
				margin-right: 15rpx;

				.right-item:last-child {
					margin-bottom: 0;
				}

				.right-title {
					display: flex;
					align-items: center;
					margin-top: 5rpx;
					color: #000;

					.name {
						font-size: 34rpx;
						font-weight: bold;
						margin-right: 14rpx;
					}

					.iconfont {
						color: #3153b5;
						font-size: 40rpx
					}
				}

				.text {
					font-size: 28rpx;
					margin-top: 30rpx;
				}

				.btn {
					width: 160rpx;
					height: 90rpx;
					background-color: #fff;
					color: #3153b5;
					font-size: 28rpx;
					margin-top: 10rpx;
					box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
				}
			}
		}

		.info-block {
			width: 100%;
			position: relative;
			padding: 30rpx;
			position: absolute;
			top: 320px;

			.title-block {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 20rpx;

				.title-item {
					display: flex;
					align-items: center;

					.line {
						width: 16rpx;
						height: 40rpx;
						border-radius: 40rpx;
						background-color: #3153b5;
						margin-right: 10rpx;
					}

					.title {
						font-size: 32rpx;
						font-weight: bold;
					}
				}

				.more {
					font-size: 28rpx;
					display: flex;
					align-items: center;
					color: #767676;

					.iconfont {
						font-size: 28rpx;
						margin-left: 4rpx;
					}
				}
			}

		}
	}
</style>